<%@page import="com.qc.entity.MerchantEntity"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
    MerchantEntity merchantEntity = (MerchantEntity)request.getSession().getAttribute("merchantEntity"); 

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

    <head>
        <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
        <link  rel="stylesheet"  type="text/css"  href="<c:url value="/css/yulan.css"/>">
        <style>
            .hides{display: none;}
            #tishi{color: red; font-size: 12px; line-height: 35px;padding-left: 10px;}
        </style>
        
        <!-- 通用CSS -->
        <jsp:include page="../lbi/merCommon.jsp"></jsp:include>
        
        <script type="text/javascript" src="<c:url value="/js/uploadPreview.js"/>"></script>
        <script type="text/javascript" src="<c:url value="/js/kindeditor/kindeditor.js"/>"></script>
        <script type="text/javascript" src="<c:url value="/js/kindeditor/lang/zh_CN.js"/>"></script>
        
        <script type="text/javascript">
        
         KindEditor.ready(function(K) {  
                ke = K.create('textarea[name="content"]', {
                    uploadJson : '<c:url value="/merchant/toFileUpload.do"/>',
                    //fileManagerJson : '<c:url value="/merchant/toFileManager.do"/>',  
                    allowFileManager : true,  
                    allowImageUpload : true,   
                   /*  autoHeightMode : true, */
                    /* afterCreate : function() {this.loadPlugin('autoheight');},   */
                    afterBlur : function(){ 
                        this.sync(); 
                    },  //Kindeditor下获取文本框信息
                    afterUpload : function(url, data, name) { //上传文件后执行的回调函数，必须为3个参数
                        if(name=="image" || name=="multiimage"){ //单个和批量上传图片时
                            var img = new Image(); img.src = url;
                            img.onload = function(){ //图片必须加载完成才能获取尺寸
                                if(img.width>600) {
                                    ke.html(ke.html().replace('<img src="' + url + '"','<img src="' + url + '" width="590"'))   
                                }
                            }
                        }
                    }
                });
            });
        
     </script>

        <title>69圈城-商家</title>
    </head>
    <body style="position: relative;">
        <!--预览-->
        <div class="bg" style="display: none;" id="y_id">
        
        </div>
        <!--预览end-->
        <!--头部-->
        <div class="business_top">
            <jsp:include page="../lbi/merHead.jsp"></jsp:include>
            <div class="clear"></div>
        </div>
        <!--头部end-->    
        
        <div class="clear4"></div>

        <!--中间-->
        <div class="individual_form-center">
            <!--左边导航部分-->
            <jsp:include page="../lbi/merLeft.jsp"></jsp:include>
            <!--左边导航部分end-->

            <!--右边详情部分-->
            <div class="individual_form-center-right">
                <!--所在位置-->
                <div class="individual_form-center-right-position">
                    <span class="span01">
                        主页发布          
                    </span>

                    <span class="span01">
                        >
                    </span>

                    <span class="span01">
                        发布主页
                    </span>
                </div>
                <!--所在位置end-->

                <div class="clear"></div>

                <div class="individual_form-center-right-details">
                    <div class="individual-form-home_release">
                        <div class="clear4"></div>
                        <form method='post' id='form' action="<c:url value="/merchant/toSaveRelease.do"/>" enctype="multipart/form-data">
                        
                            <input type="hidden" name="shopId" value="${merchantEntity.shopId }">
                            <input type="hidden" name="bId" value="${informEntity.bId }">
                            <input type="hidden" name="image" value="${informEntity.image }" />
                            
                            <input type="hidden" id="image" value="${merchantEntity.image }">
                            <input type="hidden" id="perCapitaPrice" value="${merchantEntity.perCapitaPrice }">
                            <input type="hidden" id="avgPrice" value="${merchantEntity.avgPrice }">
                            <input type="hidden" id="shopName" value="${merchantEntity.shopName }">
                            <input type="hidden" id="city" value="${merchantEntity.city }">
                            <input type="hidden" id="region" value="${merchantEntity.region }">
                            <input type="hidden" id="addressDetail" value="${merchantEntity.addressDetail }">
                            <input type="hidden" id="title" value="${merchantEntity.title }">
                            <input type="hidden" id="shopName" value="${merchantEntity.shopName }">
                            <%-- <input type="hidden" id="content" value="${merchantEntity.content }"> --%>
                             
                            
                        
                            <div class="individual-form-home_release-form">
                                <div class="individual-form-home_release-form-title">
                                    <div class="individual-form-home_release-form-title-span">
                                        标题
                                    </div>

                                    <div class="individual-form-home_release-form-title-input">
                                        <input type="text" name='title' value="${informEntity.title }" required/>
                                    </div>

                                    <div class="clear"></div>
                                </div>

                                <div class="clear2"></div>

                                <div class="individual-form-home_release-form-substance">
                                    <div class="individual-form-home_release-form-substance-span">
                                        内容
                                    </div>

                                    <div class="individual-form-home_release-form-substance-html">
                                        <textarea id="content" name="content" style="width:600px;height:500px;" required="required">
                                            ${informEntity.content }
                                        </textarea>
                                    </div>

                                    <div class="clear"></div>
                                </div>

                                <div class="clear2"></div>

                                <div class="individual-form-home_release-form-file">
                                    <div class="individual-form-home_release-form-file-span">

                                        主图
                                    </div>

                                    <div class="individual-form-home_release-form-file-input">
                                        <div id="preview" class="individual-form-home_release-form-file-input-01">
                                            <c:if test="${informEntity.image != null }">
                                                <img width="150px" height='97px' src="http://qiniu.images.69mark.com/${informEntity.image }" id="imghead" onclick="$('#previewImg').click();" />
                                            </c:if>
                                            
                                            <c:if test="${informEntity.image == null }">
                                                <img width="150px" height='97px' src="" id="home_image_img" onclick="$('#previewImg').click();" />
                                            </c:if>
                                            
                                        </div>

                                        <div class="individual-form-home_release-form-file-input-01">
                                            图片尺寸：750像素*486像素
                                        </div>

                                        <div class="individual-form-home_release-form-file-input-02" style="float: left;">
                                            <div class="individual-form-home_release-form-file-input-02-span">
                                                本地上传
                                            </div>

                                            <div class="individual-form-home_release-form-file-input-02-input">
                                                <input type="file" name='file' id="home_image_input" onchange="previewImage(this)" />
                                            </div>
                                        </div>
                                        <span id="tishi" class="hides" >请上传图像</span>
                                    </div>
                                </div>

                                <div class="clear1"></div>

                                <div class="individual-form-home_release-form-sub">

                                    <div class="individual-form-home_release-form-sub-release">
                                        <input type="submit" value="发布" id='submit_btn' />
                                    </div>
                                    <div class="individual-form-home_release-form-sub-release" style="background: none; border: 1px solid #ccc; color: #9FA0A0;">
                                        <a href="#"><input type="button" value="预览" id='yulan' style="color:#9fa0a0; cursor: pointer;"  /></a>
                                        
                                    </div>

                                    <div class="clear"></div>
                                </div>

                                <div class="clear"></div>
                            </div>
                        </form>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
            <!--右边详情部分end-->

            <div class="clear2"></div>
        </div>
        <!--中间end-->

        <div class="clear2"></div>

        <!--底部-->
        <div class="business_foot">
            <jsp:include page="../lbi/merFooter.jsp"></jsp:include>
        </div>
        <!--底部end-->

        <div class="clear8"></div>
    </body>
    
    <script type="text/javascript">
    
    $("#fabu").addClass("individual_form-center-left-nav-demo-02_dj");
    
    $("#submit_btn").click(function(){
        if($("#home_image_img").attr("src")==''){
            $("#tishi").removeClass('hides')
            return false;
        }else{
            $("#tishi").addClass('hides')
            
        }
    });
    
     $("#yulan").click(function(){
        $(".bg").show();
        
        var title = $("#title").val();
        var content = $("#content").val();
        var perCapitaPrice = $("#perCapitaPrice").val();
        var avgPrice = $("#avgPrice").val();
        var image = $("#image").val();
        var city = $("#city").val();
        var region = $("#region").val();
        var addressDetail = $("#addressDetail").val();
        var shopName = $("#shopName").val();
        
        var result = "";
        
        result += '<div class="close"><img src="<c:url value="/images/quxiao.png"/>" /></div>';
        result += '<div class="iphone">';
        result += '<div class="neirong">';
        result += '<div class="phone_bd">';
        result += '<div class="rich_media">';
        result += '<img src="http://qiniu.images.69mark.com/'+image+'"  />';
        result += '</div>';
        result += '<div class="phone_txt">';
        result += '<h3>'+title+'</h3>';
        result += '<p><span>'+perCapitaPrice+'</span><span>元／人</span></p>';
        result += '<p><del>'+avgPrice+'元／人</del></p>';
        result += '</div>';
        result += '<div class="phone_ditu">';
        result += '<div class="ditu_left">';
        result += '<span><img src="<c:url value="/images/jiudian.png"/>"  /></span>';
        result += '<span>'+shopName+'</span>';
        result += '</div>';
        result += '<div class="ditu_right">';
        result += '<img src="<c:url value="/images/tel.png"/>"  />';
        result += '</div>';
        result += '</div>';
        result += '<div class="phone_ditu">';
        result += '<div class="ditu_left">';
        result += '<span><img src="<c:url value="/images/ditu.png"/>"  /></span>';
        result += '<span>'+city+''+region+''+addressDetail+'</span>';
        result += ' </div>';
        result += '<div class="ditu_right">';
        result += '<img src="<c:url value="/images/location-(1).png"/>"  />';
        result += '</div>';
        result += '</div>';
        result += '<div class="line2"></div>';
        result += '<div class="phone_inf">';
        result += content;
        result += '</div>';
        result += '</div>';
        result += '</div>';
        result += '</div>';
        
        
        $("#y_id").html(result);
        
        $(".close").click(function(){
           $(".bg").hide();
         });
      })
     
      
    
    </script>
    

</html>
